<?php
class Admin_Form_Estate extends Zend_Form
{
    public function init()
    {
        $this->setName("admin");
        
        $esId = new Zend_Form_Element_Hidden('estateId');
        $esId->addFilter('Int');
        
        $esName = new Zend_Form_Element_Text('estateName');
        $esName->setLabel('Tên bất động sản')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $esName->setAttrib('size', 60);                                        

        $esCode = new Zend_Form_Element_Text('estateCode');
        $esCode->setLabel('Mã chữ')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $esCode->setAttrib('size', 60);
                
        $rent = new Zend_Form_Element_Checkbox('rent');
        $rent->setLabel('BĐS Cho thuê');
        $rent->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label');
                                        
        $sale = new Zend_Form_Element_Checkbox('sale');
        $sale->setLabel('BĐS Để bán')->setValue('');
        $sale->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label');        
                
        $baUtility = new Zend_Form_Element_Checkbox('baseUtility');
        $baUtility->setLabel('Tiện ích cơ bản');
        
        $otUtility = new Zend_Form_Element_Checkbox('otherUtility');
        $otUtility->setLabel('Tiện ích khác');
        
        $modelOtherInfo = new Admin_Model_Other();
        $modelList = $modelOtherInfo->getAllData(); 
        foreach($modelList as $other){                            
            $info = new Zend_Form_Element_Checkbox($other['id']);
            $info->setLabel($other['name']);                
            $info->setAttrib('name','info[]')->setCheckedValue($other['id']);
            $info->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label');
            $this->addElement($info);                                        
        }
                                
        // submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id','submitbutton');
        $submit->setAttrib('class',"button medium");
        $submit->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper');
        
        $reset = new Zend_Form_Element_Reset('reset');
        $reset->setAttrib('id','submitbutton');
        $reset->setAttrib('class',"button medium");
        $reset->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper');                
                
        // add elements to form
        $this->addElements(array (
            $esId, $esName, $esCode, $rent, $sale, $baUtility, $otUtility, $submit, $reset
        ));        
    }
}

